import { axios } from '@/utils/request'

/**
 * 根据用户ID加载用户头像
 *
 * @param userId 用户ID
 * @param ref 目标对象
 */
export function loadAvatar(userId) {
  return axios({
    url: `user/avatar/${ userId }`,
    method: 'get',
    responseType: 'arraybuffer'
  })
}

export function uploadAvatar(userId, formData) {
  return axios({
    url: `user/update/avatar/${ userId }`,
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data: formData
  })
}
